Repository navigation
Conversation
…UUIDs Three statements in the plan no longer match the code. - Numbers: a JSON document refuses a whole number from 2^53 up to 2^64 only. A whole number of 2^64 or more is stored as a float. The plan said that every unsafe integer is refused. The adapter rule is now stated for both directions, and the plan says why it differs. - Nesting: the value bridge allows 128 levels, the frame's limit. A JSON document allows 127, because the engine's JSON parser reads no deeper. The plan gave 128 for both. - UUID: the engine's dynamic value model has a UUID kind (#1929), and #1996 makes the addon encrypt a VcUuid as that kind. The plan said a UUID is refused until the engine adds one.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
coderdan
left a comment
There was a problem hiding this comment.
Review of this pull request: six wording findings in the plan. One is important: the number rules leave a large negative integer with no form that works.
| `bigint` in the tree. On encrypt, #1775 applies these rules: | ||
|
|
||
| - A whole `number` within 2^53 - 1 of zero is an integer. | ||
| - A whole `number` from 2^53 up to 2^64, on either side of zero, is |
There was a problem hiding this comment.
Important. The JSON number rules contradict each other for large negative values. A whole number between -2^64 and -2^63 is refused with "must be a bigint", but the bigint bullet refuses anything below -2^63. So json([-1e19]) is refused and the reader is told to use a bigint, and then json([-10000000000000000000n]) is refused as out of range. Neither form works.
Fix: say that a negative integer below -2^63 has no exact form and is refused either way, or narrow the refusal bullet to the range a bigint can hold.
There was a problem hiding this comment.
Fixed in 0519e06. The JSON number rules now state the gap: a negative integer below -2^63 and above -2^64 has no form in a document. The number and the bigint are both refused. The plan no longer sends the reader to a bigint for that range. It says a bigint is needed only from 2^53 up to 2^64 - 1, and from -2^53 down to -2^63.
The code in #1775 does the same thing. For json([-1e19]), json_number in value-napi/src/scalar.rs returns UnsafeInteger, because the size of the number is below 2^64. For json([-10000000000000000000n]), json_bigint returns BigIntRange, because the value does not fit an i64.
The UnsafeInteger message in value-napi/src/error.rs ends with "Pass a bigint instead." That advice is wrong for this range. It is a bug in the code of #1775, not only in the wording here. I have reported it to be fixed there.
| - A whole `number` from 2^53 up to 2^64, on either side of zero, is | ||
| refused. A `number` that large may have lost digits, so an integer | ||
| that large must be a `bigint`. | ||
| - A whole `number` of 2^64 or more is a float, as is any `number` with a |
There was a problem hiding this comment.
Minor. "A whole number of 2^64 or more is a float" covers only positive numbers, though the bullet above says "on either side of zero". The plan does not say what happens to -1e20. A wasm build written from the plan could disagree with the napi build here. Fix: state what #1775's json_number does for negatives.
There was a problem hiding this comment.
Fixed in 0519e06. The bullet now says a whole number of 2^64 or more, on either side of zero, is a float. So 1e20 and -1e20 are floats. This matches json_number in #1775 (value-napi/src/scalar.rs). The function checks the size of the number against 2^64, and its test any_other_finite_number_is_a_json_float includes -TWO_TO_64 and f64::MIN.
| @@ -978,8 +999,9 @@ The core, with no EQL: | |||
| 2. **Values.** The value bridge for every type in the table above, | |||
There was a problem hiding this comment.
Minor. Step 2 still promises "the value bridge for every type in the table above", and the table now includes VcUuid, which the same step defers until after step 3. Fix: say "every type except VcUuid", or move the UUID row out of step 2 explicitly.
| for a whole object follows the storage-blob converter (#1822), and | ||
| the UUID type the engine's (#1821). | ||
| for a whole object follows the storage-blob converter (#1822). The | ||
| UUID follows step 3, because a UUID field needs records: #1996 adds |
There was a problem hiding this comment.
Minor. Step 2 says "the UUID follows step 3, because a UUID field needs records". The table and the Values bullet say a plain VcUuid value is encrypted as a UUID once #1996 lands. Fix: say whether encrypt(new VcUuid(..)) with no record works after #1996, and make the table, the bullet and step 2 agree.
There was a problem hiding this comment.
Fixed in 0519e06. After #1996, encrypt(new VcUuid(..)) works with no record. The tests of #1996 in __tests__/addon/values.test.ts encrypt and decrypt a UUID as a value on its own, and read it back with kinds.uuid. The table row, the Values bullet, and step 2 now all say that a VcUuid encrypts as a value or in a record field. Step 2 says #1996 comes after step 3 only so that its tests can also store a UUID record field.
| as a `number`. The adapter converts, because it knows the column's type: a | ||
| `number` that is a safe integer becomes a `bigint` on the way in, and a | ||
| `bigint` becomes a `number` on the way out. An unsafe integer is refused. | ||
| `bigint` becomes a `number` on the way out. An integer outside the safe |
There was a problem hiding this comment.
Minor. The adapter rule now refuses an unsafe integer "in both directions". On the way out, that means a row whose int64 column holds a value above 2^53 (written by Go, for example) cannot be read through a Drizzle adapter. Fix: say plainly that such rows cannot be read through the adapter, or let a bigint pass through for a column typed as bigint.
There was a problem hiding this comment.
Fixed in 0519e06, following Dan's decision. The adapter section now states the rule:
- The column's TypeScript type is
number | bigint. - On the way in, a
numberthat is a safe integer becomes abigint. Abigintis accepted as it is. A wholenumberoutside the safe range is refused. - On the way out, an integer within 2^53 - 1 of zero becomes a
number, and a larger integer comes back as abigint. So the adapter can read every stored row, such as anint64above 2^53 that Go wrote.
The section no longer says "in both directions".
| decrypted value. | ||
| array and a string with an unpaired surrogate are refused. A polluted | ||
| prototype cannot add a key or see a decrypted value. | ||
| - **Nesting has two limits.** A value inside arrays and objects of values |
There was a problem hiding this comment.
Minor. The two nesting limits are counted differently: the value limit counts levels below the top value (128), and the JSON limit counts each array or object as a level (127). The text does not say which limit applies to a JSON document inside a value. Fix: state both in the same units, and say which one refuses a JSON document placed inside a value tree.
There was a problem hiding this comment.
Fixed in 0519e06. Both limits now use one unit: the top value is level 0, and each array or object puts its items one level further down.
- The bridge reads no value more than 128 levels down. That is
vitaminc_aead::frame::MAX_DEPTH. - A JSON document has no array or object more than 126 levels down, counted from the document's own top. So at most 127 nest inside one another, as
MAX_DEPTH = 127incrate/src/json.rsof feat(recipher-js): every value type, arrays and JSON documents #1775 sets.
A Json never sits inside a value tree, so only the document's own limit applies to it. In #1775, encrypt reads a Json only as one value, or as one item of an array of values (one_value in crate/src/cipher.rs). Each item is read from level 0. A Json in an array or object any deeper is refused.
- JSON numbers: a whole number of 2^64 or more is a float on either side of zero. A negative integer below -2^63 and above -2^64 has no form in a document, because the number and the bigint are both refused. - Adapter: an integer read from an integer column comes back as a bigint when it is outside the safe range, so every stored row can be read. On the way in, a whole number outside the safe range is still refused. - Nesting: both limits are now counted in levels down from the top, and the plan says a Json is never inside a value tree. - UUID: step 2 covers every type except VcUuid. After #1996, a VcUuid encrypts as a value on its own as well as in a record field.
cipherstash-agent
left a comment
There was a problem hiding this comment.
Review attestation
Reviewed 0519e06d · posted from Claude Code · claude-opus-5-5 · effort medium
Sources: code-review · claude-opus-5-5; mattpocock-skills:code-review standards and spec agents · model unknown; review-cross-check verify agent · model unknown
Skills: code-review, company-skills:rust-security (no Rust in the diff, so nothing applied), mattpocock-skills:code-review, company-skills:review-cross-check, company-skills:review-post
Findings (7): 1 major, 6 minor. 6 inline, 1 below.
docs/plans/2026-11-22-recipher-typescript-sdk.md:3(outside diff) minor The header still says "Status: proposed. Nothing in this plan is built.", but #1774 is merged intonext(8b4f20c), and this PR adds present-tense claims about #1775 and #1996. Add a revision line and update the status.
Checked and not posted: 3 findings refuted (the Json nesting wording at 628, the unqualified decrypt cell at 593, the safe-integer rule stated twice). One open question for the author: should a dated plan carry the live merge status of #1996 at all (593, 606–607)? No finding repeats the six existing threads.
Generated by Claude Code
| | `VcDate("2026-11-23")` | a calendar date | `VcDate` | | ||
| | `VcDecimal("1.50")` | a decimal, with its scale | `VcDecimal` | | ||
| | `VcUuid("..")` | refused for now, with `recipher_js::uuid` | | | ||
| | `VcUuid("..")` | a universally unique identifier (UUID), from #1996, as a value or a record field. Before #1996, refused with `recipher_js::uuid` | `VcUuid` | |
There was a problem hiding this comment.
major #1775, #1776 and #1996 name the wrapper classes RcDate, RcTimestamp, RcDecimal and RcUuid (value-napi/src/wrappers.js:80-83, renamed in f99259a, and uuid: kind<'uuid', RcUuid> in src/kinds.ts on #1996). No branch exports a Vc* class, so new VcUuid(..) written from this plan fails. This PR adds new VcUuid claims at 593, 601–607 and 1018–1022, on top of the stale Vc* names already at 382 and 590–611. Rename every Vc* to Rc*, and say once that vitaminc calls them Vc*.
Source: mattpocock-skills:code-review (spec agent), verified by review-cross-check · model unknown
Generated by Claude Code
There was a problem hiding this comment.
Fixed in f209a23. I checked the names first: value-napi/src/wrappers.js on #1775 defines RcDate, RcTimestamp, RcDecimal, and RcUuid, and next still has the Vc* names. The plan describes the API of #1775, #1776, and #1996, so every class name in the plan is now Rc*. The bullet about the wrapper classes says once that #1775 renamed them, and that vitaminc's own bridge names them Vc*.
| | `VcDate("2026-11-23")` | a calendar date | `VcDate` | | ||
| | `VcDecimal("1.50")` | a decimal, with its scale | `VcDecimal` | | ||
| | `VcUuid("..")` | refused for now, with `recipher_js::uuid` | | | ||
| | `VcUuid("..")` | a universally unique identifier (UUID), from #1996, as a value or a record field. Before #1996, refused with `recipher_js::uuid` | `VcUuid` | |
There was a problem hiding this comment.
minor The middle cell repeats the pre-#1996 refusal that the bullet at 606–607 already states, and it is much longer than every other cell in the table. Drop "Before #1996, refused with recipher_js::uuid" from the cell.
Source: mattpocock-skills:code-review (standards agent) · model unknown
Generated by Claude Code
| `bigint` in the tree. On encrypt, #1775 applies these rules: | ||
|
|
||
| - A whole `number` within 2^53 - 1 of zero is an integer. | ||
| - A whole `number` from 2^53 up to 2^64, on either side of zero, is |
There was a problem hiding this comment.
minor "from 2^53 up to 2^64" reads as including 2^64, but the next bullet makes 2^64 a float, and json_number refuses only magnitude < TWO_TO_64 (scalar.rs:142-147). Write "from 2^53 up to, but not including, 2^64", to match the "2^64 - 1" style at 679.
Source: code-review · claude-opus-5-5
Generated by Claude Code
| So `1e20` and `-1e20` are floats. Any `number` with a fraction is a | ||
| float too. |
There was a problem hiding this comment.
minor The rule list gives no rule for NaN, Infinity and -Infinity, which #1775 refuses (json_number returns NoJsonForm::NonFinite, scalar.rs:140-141). The json doc comment (crate/src/json.rs:136) does state the rule. Add "NaN and the infinities are refused."
Source: mattpocock-skills:code-review (spec agent) · model unknown
Generated by Claude Code
There was a problem hiding this comment.
Fixed in f209a23. The text under the table now says "NaN and the infinities are refused." For those values, json_number returns NoJsonForm::NonFinite.
| - A `bigint` is written as its digits, from -2^63 to 2^64 - 1. A | ||
| `bigint` outside that range is refused. | ||
|
|
||
| So a positive integer from 2^53 up to 2^64 - 1 must be a `bigint`. So |
There was a problem hiding this comment.
minor Two sentences in a row open with "So", and the interval rules at 670–682 make the reader do the off-by-one arithmetic. A small table with columns for range, number and bigint would state them in one place.
Source: mattpocock-skills:code-review (standards agent) · model unknown
Generated by Claude Code
There was a problem hiding this comment.
Fixed in f209a23. The rules are now one table with three columns: the range of whole numbers, the result as a number, and the result as a bigint. Each range includes both ends, so the reader does not need to work out the edges. The two sentences that started with "So" are gone.
The table also shows a change to #1775, made in 5c78ecf. A whole number below -2^63 and above -2^64 is now refused with its own message. The message says the integer has no exact form. The message no longer asks for a bigint.
| The `eql-json-v1` case that contains `18446744073709551615` round-trips | ||
| on both builds. |
There was a problem hiding this comment.
minor No code backs "round-trips on both builds". Nothing in recipher-js reads eql-json-v1 on #1775, #1776 or #1996, and there is no wasm build yet. Only __tests__/addon/values.test.ts:282-290 round-trips 2^64 - 1, on the native addon. The sentence now sits under "On encrypt, #1775 applies these rules", so it reads as built. Cite that test for the native build, and mark the wasm half as planned. (The edit from "holds" to "contains" here changes no meaning.)
Source: mattpocock-skills:code-review (spec and standards agents) · model unknown
Generated by Claude Code
There was a problem hiding this comment.
Fixed in f209a23. I checked this: nothing in recipher-js reads eql-json-v1, and there is no wasm build. The plan now says the native build round-trips 2^64 - 1 in the #1775 test "keeps an integer outside the safe range as a bigint" (__tests__/addon/values.test.ts). It says the wasm build is not built yet, and that the plan is for it to pass the same test and the eql-json-v1 case.
The second review of #2019 found the plan out of step with the code. - The wrapper classes are RcDate, RcTimestamp, RcDecimal, and RcUuid in #1775, #1776, and #1996. The plan used vitaminc's Vc names. The plan now uses the Rc names, and says once that #1775 renamed them. - The JSON number rules are now one table, with a row for each range of whole numbers. Each range includes both ends. The table shows the new refusal below -2^63. That refusal says the integer has no exact form. The plan also says that NaN and the infinities are refused. - The round trip of 2^64 - 1 is tested on the native build only. The plan now names that test, and says the wasm build is planned. - The UUID cell no longer repeats the refusal before #1996. - The header now gives the status. Step 1 is built. The next steps are in open pull requests.
|
Reply to the finding in review 6101095709 that has no thread (the status line, outside the diff):
|
Summary
Three statements in
docs/plans/2026-11-22-recipher-typescript-sdk.mdno longer match the code. This pull request corrects them. Some of the rules come from pull requests that are still open. The plan now names them: #1775 for the number rule and the JSON nesting limit, and #1996 for UUID support.Changes
Vc*names for the wrapper classes. The classes were renamed in feat(recipher-js): every value type, arrays and JSON documents #1775, so the plan now usesRcDate,RcTimestamp,RcDecimal, andRcUuid, and says once where the old names come from.numberfrom 2^53 up to 2^64, either side of zero. A wholenumberof 2^64 or more is stored as a float. Abigintis stored from -2^63 to 2^64 - 1, and refused outside that range. So a negative integer below -2^63 and above -2^64 has no form in a document. The code in feat(recipher-js): every value type, arrays and JSON documents #1775 now refuses such anumberwith its own message (5c78ecf) instead of asking for abigint. The plan now lists these rules in one table. The adapter rule for integer columns is a design with no code yet. The rule now follows Dan's decision. On the way out, an integer outside the safe range comes back as abigint, so every stored row can be read. On the way in, a wholenumberoutside the safe range is refused.json(..). The plan now states both limits in one unit, and says that aJsonis never inside a value tree.RcUuidis refused until the engine adds a UUID. The engine's dynamic value model has hadValueKind::Uuidsince refactor(stack-encrypt)!: each index says which kinds it takes; add the uuid kind #1929, with an equality index only. The code in feat(recipher-js): encrypt a VcUuid as the engine's UUID #1996 makes the addon encrypt aRcUuidas that kind, as a value on its own or in a record field. The table row, the Values bullet, step 2 of the build order, and the list of findings from steps 1 to 3 now say this. Each one says the SDK refuses aRcUuiduntil feat(recipher-js): encrypt a VcUuid as the engine's UUID #1996 merges.Verification
I checked each statement against the code:
json_numberandjson_bigintinlanguages/typescript/packages/recipher-js/value-napi/src/scalar.rs, lines 121 to 177 onfeat/recipher-js-values. The doc comment ofjsonincrate/src/json.rs, lines 126 to 141, states the same rules.MAX_DEPTH = 127incrate/src/json.rsline 39, and the test "nests 127 levels deep and refuses 128" in__tests__/addon/values.test.tsline 538, both onfeat/recipher-js-values. The value limit isvitaminc_aead::frame::MAX_DEPTH(128), used byvalue-napi/src/js.rsline 19 onnext.ValueKind::Uuidanda_uuid_admits_equality_aloneinpackages/stack-encrypt/src/dynamic/kind.rsonnext. The diff of feat(recipher-js): encrypt a VcUuid as the engine's UUID #1996 against feat(recipher-js): records through the engine's Planned #1776 removes therecipher_js::uuidrefusal fromcrate/src/js.rs.The plain-language checker reports no "must fix" findings on the added lines. This pull request changes a plan only, so I ran no code checks.
Related